//
// Created by redcat1 on 03.05.2024.
//

#include "test_vector_.h"
#include "test_dsl.h"
#include "vector_.h"
#include <iostream>


//
TEST(Vector, Construct_Normal)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(5, 7.5);
  ASSERT_EQ("{7.5, 7.5, 7.5, 7.5, 7.5}", v.ToString());
}

//
TEST(Vector, Construct_Empty)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(0, 7.5);
  ASSERT_EQ("{}", v.ToString());
}

//
TEST(Vector, Construct_NegativeSize)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(-5, 7.5);
  ASSERT_EQ("{}", v.ToString());
}

//
TEST(Vector, Construct_BiggerThanBuffer)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(12, 7.5);
  ASSERT_EQ("{7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5}", v.ToString());
}

//
TEST(Vector, AtConst_Normal)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(5, 7.5);
  ASSERT_NEAR(7.5, v[3], 0.0001);
}

//
TEST(Vector, AtConst_NegativeIndex)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(5, 7.5);
  ASSERT_NEAR(0.0, v[-1], 0.0001);
}

//
TEST(Vector, AtConst_TooBigIndex)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(5, 7.5);
  ASSERT_NEAR(0.0, v[12], 0.0001);
}

//
TEST(Vector, At_Normal)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(5, 7.5);
  v[3] = 1.5;
  ASSERT_NEAR(1.5, v[3], 0.0001);
}

//
TEST(Vector, At_NegativeIndex)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(5, 7.5);
  v[-1] = 1.5;
  ASSERT_NEAR(1.5, v[-1], 0.0001);
}

//
TEST(Vector, At_TooBigIndex)
{
  std::cout << "Running " << __func__ << "\n";
  Vector v(5, 7.5);
  v[12] = 1.5;
  ASSERT_NEAR(1.5, v[12], 0.0001);
}

//
void RunVectorTests()
{
  RUN_TEST(Vector, Construct_Normal);
  RUN_TEST(Vector, Construct_Empty);
  RUN_TEST(Vector, Construct_NegativeSize);
  RUN_TEST(Vector, Construct_BiggerThanBuffer);
  RUN_TEST(Vector, AtConst_Normal);
  RUN_TEST(Vector, AtConst_NegativeIndex);
  RUN_TEST(Vector, AtConst_TooBigIndex);
  RUN_TEST(Vector, At_Normal);
  RUN_TEST(Vector, At_NegativeIndex);
  RUN_TEST(Vector, At_TooBigIndex);
}